package com.servlet;

import com.dao.StudentDao;
import com.bean.Student;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SearchServlet extends HttpServlet{
    public void doPost(HttpServletRequest request,HttpServletResponse response)
            throws ServletException,IOException{
        String id = request.getParameter("id");
        Student stu = StudentDao.searchStudent(id);
        System.out.println(stu);
        if(stu!=null){
            request.getSession().setAttribute("stu", stu);
            RequestDispatcher view = request.getRequestDispatcher("/display.jsp");
            view.forward(request, response);
        }else{
            RequestDispatcher view = request.getRequestDispatcher("/errorPage.jsp");
            view.forward(request, response);
        }
    }
}
